package com.flx.task;

import com.flx.websocket.WebSocketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @ClassName WebSocketTask
 * @Description TODO
 * @Author 23207
 * @Date 2025/4/29 13:35
 * @Version 1.0
 */
@Component
public class WebSocketTask {

  @Autowired
  private WebSocketService webSocketService;

  @Scheduled(cron = "0/5 * * * * ?")
  public void sendMessage() {
    webSocketService.sendToAllUser("这是一条来自服务端的消息:" + LocalDateTime.now());
  }
}
